home *** CD-ROM | disk | FTP | other *** search
- QLIB5 EMS.DOC expanded memory subroutines
- Copyright (C) 1991 Douglas Herr
- All rights reserved
-
-
- Expanded Memory subroutines take advantage of expanded memory conforming
- to the Lotus/Intel/Microsoft (LIM) Expanded Memory Specification (EMS).
- QLIB EMS subroutines allow your programs to store vast amounts of data in
- Expanded memory rather than creating temporary files on a disk. A well-
- designed program using Expanded memory can be much faster than if Expanded
- memory isn't used.
-
- Three primary versions of the EMS have been released: 3.0, 3.2 and 4.0.
- QLIB's EMS subroutines will work with all EMS versions.
-
- EMS memory is allocated in "pages" of 16k bytes (actually 16,384 bytes)
- each.
-
- Error codes returned by QLIB's EMS subroutines are:
-
- 0 = no error
- &H80 = memory manager software error - non-recoverable
- &H81 = expanded memory hardware error - non-recoverable
- &H83 = invalid EMS handle
- &H85 = no available EMS handles
- &H87 = not enough memory pages
- &H88 = not enough memory pages available
- &H89 = you tried to allocate zero pages
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSclose(handle%, oops%)
- object file: ems30.obj
-
- Closes an EMS "file" opened by EMSopen and releases the
- associated expanded memory. DOS will not release expanded memory
- when the program ends, so you must use EMSclose for all open EMS
- "files" before the program ends.
-
- Example:
- CALL EMSclose(handle%, oops%)
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSopen(pages%, handle%, oops%)
- object file: ems30.obj
-
- "Opens" an EMS "file" for subsequent operations. You specify
- how many EMS pages you want (16k bytes, each page), and EMSopen
- returns a handle to use in read/write operations. DOS will not
- release expanded memory when the program ends, so you must use
- QLIB's EMSclose for all "open" EMS "files" before the program ends.
- A maximum of 4 EMS pages (64k bytes) may be allocated to each handle.
-
- Example:
- CALL EMSopen(pages%, handle%,oops%)
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: r% = EMSReady
- object file: ems30.obj
-
- Determines if EMS memory is installed in the computer. Returns
- r% = -1 if EMS is installed, r% = 0 if not.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
-
- IF EMSReady THEN
- PRINT "EMS is installed"
- ELSE
- PRINT "no EMS memory or driver not installed"
- END IF
-
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSVersion(maj%, min%)
- object file: ems30.obj
-
- Determines EMS version installed. Use EMSReady to determine if
- EMS memory is installed.
-
- Example:
- CALL EMSVersion(maj%, min%)
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSSize(total%, free%)
- object file: ems30.obj
-
- Determines the number of EMS memory pages available. Use EMSReady
- to determine if EMS memory is installed.
-
- Example:
- CALL EMSSize(total%, free%)
-
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSread(handle%, aseg%, aptr%, emsptr%, bytes%, oops%)
- object file: emsrw.obj
-
- Copies data from an EMS file opened by EMSopen to an array.
- aseg% and aptr% are segment and offset pointers to the array, bytes%
- is the number of bytes to be copied, and handle% is the handle returned
- by EMSopen. EMSptr% is the byte offset in the EMS "file" where you
- want the read to start. Note that EMSptr% = 0 at the start of the
- "file". If you want to read more than 32767 bytes from EMS memory
- (up to 65,535), you should use a long integer bytes& instead of the
- integer bytes%.
-
- Example:
- CALL EMSread(handle, aseg%, aptr, emsptr%, bytes%, oops%)
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSwrite(handle%, aseg%, aptr%, emsptr%, bytes%, oops%)
- object file: emsrw.obj
-
- Copies data from an array to an EMS file opened by EMSopen.
- aseg% and aptr% are segment and offset pointers to the array, bytes%
- is the number of bytes to be copied, and handle% is the handle returned
- by EMSopen. EMSptr% is the byte offset in the EMS "file" where you
- want the write to start. Note that EMSptr% = 0 at the start of the
- "file". If you want to read more than 32767 bytes from EMS memory
- (up to 65,535), you should use a long integer bytes& instead of the
- integer bytes%.
-
- Example:
- CALL EMSwrite(handle, aseg%, aptr, emsptr%, bytes%, oops%))
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSRead1(handle%, value%, e%, oops%)
- Subroutine: EMSRead2(handle%, value%, e%, oops%)
- Subroutine: EMSRead4(handle%, value, e%, oops%)
- Subroutine: EMSRead8(handle%, value, e%, oops%)
- object file: emsrw1.obj
-
- EMSRead[n] subroutines copy a value from element e% of an array
- stored in expanded memory. In each case, Value is an n-byte number:
- EMSRead1 is for QLIB's 1-byte short integers, EMSRead2 is for 2-byte
- integers, EMSRead4 is for 4-byte long integers or single-precision real
- numbers, EMSRead8 is for 8-byte double-precision real numbers or for
- BC7's CURRENCY integers. Oops% returned by EMSRead[n] is an EMS
- error code.
-
- Since value's data type is ambiguous in EMSRead4 and EMSRead8,
- be sure that you are using the data type you intended.
-
-
- Example:
- REM A SINGLE array has been stored in expanded memory, but
- REM I need to see what the 18th element of the array is.
- REM The 18th element is e% = 17, since the first element is
- REM e% = 0
-
- e% = 17
- CALL EMSRead4(handle%, value!, e%, oops%)
- a$ = "The 18th element is" + STR$(value!)
- PRINT a$
-
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: EMSWrite1(handle%, value%, e%, oops%)
- Subroutine: EMSWrite2(handle%, value%, e%, oops%)
- Subroutine: EMSWrite4(handle%, value, e%, oops%)
- Subroutine: EMSWrite8(handle%, value, e%, oops%)
- object file: emsrw1.obj
-
- Replaces element e% of an array stored in expanded memory
- with a value. This subroutine is the complement of EMSRead[n].
- See EMSRead[n] for example.